package day5

// 加 case 成为样例类
case class Student (var name:String,sort:Int)

object Test3_groupBy {
  def main(args: Array[String]): Unit = {
    val list = List( Student("王也", 95), Student("余生", 92), Student("紫霞", 92), Student("青霞", 92) )
    list.foreach((v) => println(v))
    val map: Map[Any, List[Student]] = list.groupBy((v: Student) => v.name)

    map.foreach((v) => println(v))
    for (elem <- map) {
      println(elem)
    }
    println(map)
  }
}
